const { Sequelize } = require('sequelize')
const initModels = require('../models/init-models')
const dbConfig = require('config-lite')(__dirname).db

const sequelize = new Sequelize(
  {
    database: dbConfig.database,
    dialect: dbConfig.type,
    host: dbConfig.host,
    port: dbConfig.port,
    password: dbConfig.password,
    username: dbConfig.username
  }
)
// 引入models
const models = initModels(sequelize)
module.exports = { sequelize, models }
